
/**
 * created on 2012-04-25
 * @author  qiujz
 * @version 1.0
 *
 * Copyright (c)  Founder Software (Suzhou) Co., Ltd.  2012
 *  All rights reserved.
 *
 * 
 * ================================================================
 * Change Revision
 * ---------------------------------------------------------------
 *    DATE                BY                   COMMENT
 * ---------------------------------------------------------------
 * 2012-04-25         qiujz                Create class
 * 
 *
 * ================================================================
 */	

package com.qjz.dao.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.founder.mh.framework.dao.impl.BaseDaoImpl;
import com.qjz.dao.IStudentInfoDao;
import com.qjz.entity.DistinctTo;
import com.qjz.entity.StudentInfoTo;	

public class StudentInfoDaoImpl extends BaseDaoImpl implements IStudentInfoDao {
	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #searchStudentInfoList(java.util.Map)
	 */
	public List<StudentInfoTo> searchStudentInfoList(
			Map<String, Object> paramMap) {
		return this.queryForList("studentInfo.searchStudentInfo", paramMap);
	}

	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #searchStudentInfoPagination(java.util.Map, int, int)
	 */
	public List<StudentInfoTo> searchStudentInfoPagination(
			Map<String, Object> paramMap, int startRow, int endRow) {
		return this.queryForListPagination("studentInfo.searchStudentInfo",
				paramMap, startRow, endRow);
	}
	
	public List<StudentInfoTo> searchStudentInfoPagination(Map<String, Object> paramMap){
		return this.queryForList("studentInfo.searchStudentInfoPagination", paramMap);
	}
	
	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #getStudentInfoCount(java.util.Map)
	 */
	public Integer getStudentInfoCount(Map<String, Object> paramMap) {
		return (Integer) this.queryForObject("studentInfo.getStudentInfoCount", paramMap);
	}
	
	
	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #getStudentInfoByPrimaryKey(String)
	 */
	public StudentInfoTo getStudentInfoByPrimaryKey(int sfid) {
		return (StudentInfoTo) queryForObject("studentInfo.getStudentInfoByPrimaryKey", sfid);
	}
	

	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #insertStudentInfo(com.qjz.entity.StudentInfoTo)
	 */
	public Object insertStudentInfo(StudentInfoTo studentInfo) {
		return this.create("studentInfo.insertStudentInfo", studentInfo);		
	}

	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #updateStudentInfoByBean(com.qjz.entity.StudentInfoTo)
	 */
	public int updateStudentInfoByBean(StudentInfoTo studentInfo) {
		return this.update("studentInfo.updateStudentInfo.byBean", studentInfo);
	}

	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #updateStudentInfoByProperty(java.util.Map)
	 */
	public int updateStudentInfoByProperty(Map<String, Object> paramMap) {
		return this.update("studentInfo.updateStudentInfo.byProperty", paramMap);
	}

	
	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #deleteStudentInfoByPrimaryKey(String)
	 */
	public int deleteStudentInfoByPrimaryKey(int sfid) {
		return this.delete("studentInfo.deleteStudentInfoByPrimaryKey", sfid);
	}
	
	/** 
	 * @inheritDoc
	 * @see com.qjz.dao.IStudentInfoDao
	 *      #deleteStudentInfoBatch(String[])
	 */
	public void deleteStudentInfoBatch(String[] keyArray) {
		SqlMapClient sqlMap = this.getSqlMapClient();
		try {
			sqlMap.startBatch();
			for (String key : keyArray) {
				sqlMap.delete("studentInfo.deleteStudentInfoByPrimaryKey",
						key);
			}
			sqlMap.executeBatch();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public int deleteStudentInfoByParamter(Map<String, Object> paramMap) {
		return this.delete("studentInfo.deleteStudentInfoByParamter", paramMap);
	}
	
	public void insertStudentInfoBatch(List<StudentInfoTo> list){
		SqlMapClient sqlMap = this.getSqlMapClient();
		try {
			sqlMap.startBatch();
			for (StudentInfoTo student : list) {
				sqlMap.insert("studentInfo.insertStudentInfo",
						student);
			}
			sqlMap.executeBatch();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
		
	public List<DistinctTo> searchDistinctList(){
		return this.queryForList("studentInfo.searchDistinctList");
	}

	@Override
	public List<DistinctTo> searchBanJiList(String school) {
		return this.queryForList("studentInfo.searchBanJiList", school);
	}
}	
	
